home *** CD-ROM | disk | FTP | other *** search
- /* HVHiP.AMIRX by Johan Forsberg & Daniel Widerström
- $VER: HVHiP.amirx 1.0 (98.10.05)
-
- What?
- ----------------------------------------------------------------
- A convenient way to play High Voltage SIDs (or possibly other
- SIDs :) in HippoPlayer, without leaving AmIRC or even touching
- that awful mouse thingy. Theoretically it could be used for
- other kinds of music modules too... but hey, that's not what
- it's for!
-
-
- Well?
- ----------------------------------------------------------------
- 0: Get the High Voltage SID Collection... but we assume you've
- already got that. Hasn't everybody? :)
- You can find them at:
- http://www.dhp.com/~shark/c64music/hv_sids/
- if you don't. You don't actually *need* to have all of them
- for this script to work, but you can never have too many
- SIDs, so why not grab'em?
-
- 1: Put this script in .../AmIRC/rexx/
-
- 2: Get "grep" and put it somewhere in your path (C: maybe?)
- Should be GNU grep, or else you'll probably have to modify
- the call. SAS grep can be made to work, anyway. GNU grep
- can be found on Aminet and is much faster than AmigaDOS'
- 'search' command.
-
- 3: Add an alias to AmIRC, for example:
- /alias sid /rx HVHiP.AMIRX %p
- Make sure you have SYS:System/RexxMast running (put it in
- your startup somewhere, perhaps).
-
- 4: Set your HV SIDs path by writing (in AmIRC):
- /sid -setpath Your:High/Voltage/SIDs/Path/C64Music/
-
- ...your HippoPlayer path:
- /sid -sethip Your:Hippo/Player/Path/
-
- ...decide whether you'd like HVHiP to echo everything:
- /sid -setecho 0 *or* /sid -setecho 1
-
- ...set the message type for AmIRC echoes:
- /sid -setcolor 4 (Argument range is 1-7)
-
- ...set maximum number of hits reported in AmIRC:
- /sid -setmax 50
-
-
- 5: Whenever you're ready for some SID action, simply type
- /sid Whatever
- This will cause the script to look for a SID with a name
- containing the word "whatever" (the search is not case
- sensitive.) Because grep is used for matching words, you
- can utilize grep's regular expressions for some advanced
- searching. If you only want the script to play SIDs which
- exactly match the name you gave, you might want to write:
- /sid /Commando.sid
- Oh, and as a side effect, you're able to search for authors
- in the same way, i.e:
- /sid Hubbard_Rob/
-
- There are a couple of commands you can pass to the script.
- Some of them require an argument:
- P = search pattern, S = string, N = number, [] = optional
-
- -add P Just add files, don't play them
- -new [P] Clears playlist before adding any new ones
- -rand Randomly selects/plays another SID from the list.
- -next Selects/plays next song from list.
- -prev Selects/plays prev song from list.
- -nsub Selects/plays next subsong
- -psub Selects/plays prev subsong
- -sub [N] Selects/plays arg. (No arg plays 1)
- -pause Toggle pause on/off in HiP
- -sort Sort your playlist alphabetically
- -test P Makes the search, but won't add any files to HiP.
- -setpath S Sets your HVSids path. Specify path as second argu-
- ment, and remember that the "C64Music" directory
- must be *included* in the path.
- -setecho N Sets whether you want the search results echoed in
- your AmIRC view or not. Second argument should be
- either 0 or 1.
- -sethip S Sets Hippoplayer path, don't have Hip in it
- -setcolor N Set color type to use in AmIRC messages.
- -setmax N Set max sid to echo when setecho is 1.
- -prefs Echo your prefs
-
- Commands are optional, but you can only give one command
- at a time. The command must be put before any search pattern.
- Don't forget the "-" before a command, or it will be inter-
- preted as a search pattern. If neither commands or arguments
- are passed, a list of available commands is echoed.
-
- All the settings are stored in an environment variable called
- "HVHiP.prefs". The script also generates an index file over
- your HV SIDs directory which is called "S:hvSIDs.index", and
- temporarily stores grep output in T:. The index file is auto-
- matically generated the first time you run the script (or if
- the index is missing - remove the index every time you update
- your HV SIDs if you want the script to be up-to-date) which
- might take a few minutes.
-
-
- Why?
- ----------------------------------------------------------------
- Because we just love Sids, HippoPlayer and IRC :)
- And because it's so pointless it just had to be done.
-
-
- Who?
- ----------------------------------------------------------------
- Johan Forsberg (Johan.Forsberg.6117@student.uu.se), who started
- writing the script, and Daniel Widerström (rutgers@mhd.mh.se)
- who came up with the original idea and got involved in writing
- it too. Both are often found on IRC, mainly on IRCNet/#AmigaSWE
- under aliases "Agrajag" and "Rutgers", respectively.
-
-
- When?
- ----------------------------------------------------------------
- 1.0 Final release, uploaded to Aminet. (D)
-
- 0.3 some refinements of the "readme" part and small cleanup (J)
- some betatesting has been made :)
-
- 0.24 added -psub (D)
- added -setcolor (D)
- added -setmax (D)
- added -sub (D)
- added -add (D)
- fix bugg when command -command isn't support (D)
-
- 0.23 added -sort (D)
- added -nsub (D)
- fixed broken -test (J)
-
- 0.22 automatically generate s:hvsids.index (J)
- Start HiP if isn't running (D)
- added -prefs (D)
- change prefs write, and add Hippoplayer path (D)
- change -next to -rand and -next is really next now (D)
- added -prev (D)
-
- 0.21 fix check if Hippoplayer is running (D)
- Don't search for "" (D)
-
- 0.2 translated the manual into english (J)
- put some user prefs in an environment variable (J)
- added -setpath (J)
- added -setecho (J)
- added -test (J)
- some lame errorchecking (J)
- general cleanup (J)
-
- 0.13 got rid of a bug that caused HiP to go wild when no Sid
- would match the given word. Stupid! (J)
-
- 0.12 added version with no argument (D)
- added command interpreter (D)
- added -new (D)
- added -next (D)
- added -pause (D)
-
- 0.11 added check whether Hippoplayer is running (D)
- added credits for Daniel Widerström (Daniel)
-
- 0.1 first alpha version (*very* basic) (Johan)
-
-
- Whoops?
- ----------------------------------------------------------------
- This piece of software is completely free and you can do with it
- whatever you like. However, we do not take *any* responsibility
- for what might happen if you use it, even if you follow all
- instructions to the letter. This script works pretty well on
- our machines, but it might very well blow up in your face. So
- be warned. Not that anything bad actually *will* happen. :)
- But if it should bomb for whatever reason, you might want to
- tell us about it, even if you can fix the problem by yourself.
- That way someone else with the same problem might be helped too!
- Also, none of us are too well aquainted with ARexx, so if you
- happen to be a real guru, and spot something stupid, ineffective
- or downright dangerous in the code - why not drop us a line?
- Any other comments or suggestions of any kind are most welcome!
-
-
- TODO :
- ----------------------------------------------------------------
- More testing
- add -next|-prev|etc. can take [N]
- Probably should add more errorchecking... D'oh!
-
- */
-
- version='1.0 (98.10.05)'
-
- Hip_path=''
-
- HVSids_path=''
-
- echo=''
-
- maxsid=''
-
- colorecho=''
-
- options results
-
- PARSE ARG Arg1 Arg2
-
- Arg1=strip(Arg1)
- Arg2=strip(Arg2)
-
- amirc_host=address()
-
- /*Check for commands involving prefs...*/
-
- if Arg1="-setpath" then do
- HVSids_path=Arg2
- call WritePrefs
- call write "Setting path..."
- exit
- end
-
- if Arg1="-setecho" then do
- echo=Arg2
- call write "Setting echo..."
- call WritePrefs
- exit
- end
-
- if Arg1="-sethip" then do
- Hip_path=Arg2
- call write "Setting Hip..."
- call WritePrefs
- exit
- end
-
- if Arg1="-setcolor" then do
- colorecho=Arg2
- call write "Setting color..."
- call WritePrefs
- exit
- end
-
- if Arg1="-setmax" then do
- maxsid=Arg2
- call write "Setting max..."
- call WritePrefs
- exit
- end
-
- /* call WRITE "Hejsan!" */
-
-
- if open(prefs,'ENV:HVHiP.prefs',R) then do
-
- HVSids_path=readln(prefs)
- Hip_path=readln(prefs)
- echo=readln(prefs)
- colorecho=readln(prefs)
- maxsid=readln(prefs)
-
- close(prefs)
-
- if echo='' then echo=0
- if colorecho='' then colorecho=2
- if maxsid='' then maxsid=50
-
- if Arg1="-prefs" then do
- call write "HVSid Path = "HVSids_path
- call Write "Hippoplayer Path = "Hip_path
- call write "Write Echo = "echo
- call write "Echo ColorType = "colorecho
- call write "Echo Max = "maxsid
- exit
- end
-
- /* Check if any arg */
-
- if Arg1="" then DO
-
- Call VERSION
- Call USAGE
- EXIT
- END
-
- if HVSids_path='' then do
- call write "Your HVSids path is empty!"
- EXIT
- end
-
- if hip_path='' then do
- call write "Your Hippoplayer path is empty!"
- EXIT
- end
-
- /*If the index file doesn't exist - create it!*/
-
- if ~(open(index,'s:hvsids.index',R)) then do
-
- call write "Index file missing - creating it (may take a few minutes...)"
-
- address command 'cd 'HVSids_path '0a'x 'list lformat=%P%N all files >t:hvindex.tmp'
- address command 'sort t:hvindex.tmp to s:hvsids.index'
- address command 'delete t:hvindex.tmp'
-
- end
-
- else close(index)
-
- /*Check for commands*/
-
- argtemp=left(Arg1,1)
-
- if argtemp="-" then do
-
- if ~(Arg1="-test") then do
- err=show('P','HIPPOPLAYER')
-
- if err=0 then do
- call write "Starting HippoPlayer..."
- address command ''hip_path'hip'
- address command 'WaitForPort HIPPOPLAYER'
- END
- END
-
- address 'HIPPOPLAYER'
-
- SELECT
-
- When Arg1="-rand" then do
- 'RANDPLAY'
- EXIT
-
- END
-
- When Arg1="-next" then do
-
- address value amirc_host
- getchannel
- address
-
- GET NFIL
- maxmod = result
-
- GET CFIL
- current = result
-
- CHOOSE current+1
- IF current+1 > maxmod then 'CHOOSE' 1
-
- 'PLAY'
-
- EXIT
- END
-
- When Arg1="-prev" then do
-
- address value amirc_host
- getchannel
- address
-
- GET CFIL
- current = result
-
- CHOOSE current-1
-
- 'PLAY'
-
- EXIT
- END
-
- When Arg1="-nsub" then do
-
- address value amirc_host
- getchannel
- address
-
-
- GET NSNG
- maxsong = result
-
- GET CSNG
- current = result
-
- IF (current+1) > maxsong then SONGPLAY 0
- ELSE SONGPLAY (current+1)
-
- EXIT
- END
-
- When Arg1="-psub" then do
-
- address value amirc_host
- getchannel
- address
-
- GET CSNG
- current = result
-
- GET NSNG
- maxsong = result
-
- IF (current) < 2 THEN SONGPLAY maxsong
- ELSE SONGPLAY (current-1)
-
- EXIT
- END
-
- When Arg1="-sub" then do
-
- address value amirc_host
- getchannel
- address
-
- GET NSNG
- maxsong = result
-
- if ARG2 > maxsong then SONGPLAY maxsong
- ELSE SONGPLAY ARG2
-
- EXIT
- END
-
- When Arg1="-sort" then do
-
- call write "sort songs"
-
- 'SORT'
- EXIT
- END
-
- When Arg1="-new" then do
-
- 'CLEAR'
- 'EJECT'
- if Arg2="" then exit
- END
-
- When Arg1="-pause" then do
-
- address value amirc_host
-
- getchannel
-
- address
-
- get play
-
- if result == 1 then 'STOP'
- ELSE 'CONT'
-
- EXIT
-
- END
-
- When Arg1="-test" then do
-
- END
-
- When Arg1="-add" then do
-
- END
-
- OTHERWISE
-
- address value amirc_host
-
- call write "command "arg1" is not supported"
-
- EXIT
- END
-
- END
-
- /*No commands specified?*/
-
- ELSE DO
- Arg2=Arg1
- END
-
-
- /*Get down to business...*/
-
- if echo=1 then call version
-
- address command 'grep -i "'Arg2'" s:hvsids.index >t:HVgrep.tmp'
-
- i=1 /*Counter*/
-
- if open(temp,'t:HVgrep.tmp',R) then do
-
- /*Get results from grep search...*/
-
- do until eof(temp)
- path.i=readln(temp)
- i=i+1
- end
-
- close(temp)
-
- address command 'delete t:HVgrep.tmp QUIET'
-
- /*...if there _were_ any results...*/
-
- if i>2 then do
-
- if ~(Arg1="-test") then do
- err=show('P','HIPPOPLAYER')
-
- if err=0 then do
- call write "HippoPlayer isn't running! I'll try to start it..."
- address command ''hip_path'hip'
- address command 'WaitForPort HIPPOPLAYER'
- END
- END
-
- address 'HIPPOPLAYER'
-
- n=1 /*Other counter*/
-
- do until n = i-1
-
- /*Add files to Hippo*/
-
- if ~(Arg1="-test") then do
- address 'HIPPOPLAYER'
- add HVSids_path || path.n
- end
-
- /*Echo filenames to AmIRC*/
-
- if echo=1 & n<maxsid+1 then do
- address value Amirc_host
- "echo P="n" C="colorecho" "path.n""
- end
-
- n=n+1
- end
-
- /*Play it, Sam*/
-
- if ~(Arg1="-test") & ~(Arg1="-add") then do
- address 'HIPPOPLAYER'
- choose 1
- play
- END
-
- address
-
- if (Arg1="-test"|n>maxsid+1) then Call write "---File count: "n-1"---"
-
- end
-
- else call write "Sorry, no HVSids found matching '"Arg2"'"
-
- end
-
- ELSE DO
- "ECHO P=DEBUG Something weird has occurred!"
- EXIT
- end
-
- end
-
- else call write "No prefs variable found! Please create one, using -setXXX commands."
-
- EXIT
-
-
- /* Functions */
-
- WritePrefs:
-
- /*Updates/creates the envvar "HVHiP.prefs" with current settings*/
-
- if open(prefs,'ENV:HVHiP.prefs',R) then do
-
- if HVSids_path='' then HVSids_path=readln(prefs)
- else readln(prefs)
-
- if Hip_path='' then Hip_path=readln(prefs)
- else readln(prefs)
-
- if echo='' then echo=readln(prefs)
- else readln(prefs)
-
- if colorecho='' then colorecho=readln(prefs)
- else readln(prefs)
-
- if maxsid='' then maxsid=readln(prefs)
- else readln(prefs)
-
- close(prefs)
-
- open(prefs,'ENV:HVHiP.prefs',W)
- writeln(prefs,HVSids_path)
- writeln(prefs,Hip_path)
- writeln(prefs,echo)
- writeln(prefs,colorecho)
- writeln(prefs,maxsid)
-
- end
-
- else do
-
- open(prefs,'env:HVHiP.prefs',W)
- writeln(prefs,HVSids_path)
- writeln(prefs,Hip_path)
- writeln(prefs,echo)
- writeln(prefs,colorecho)
- writeln(prefs,maxsid)
-
- end
-
- close(prefs)
-
- address command 'copy ENV:hvsids.prefs ENVARC:hvsids.prefs'
-
- return
-
-
- ADD:
-
- n=1
-
- do until n = i-1
- add HVSids_path || path.n
- n=n+1
- end
-
- RETURN
-
-
- WRITE:
-
- parse arg text
-
- address value amirc_host
-
- if colorecho='' then "ECHO P=HVHiP C=2 "text
- ELSE "ECHO P=HVHiP C="colorecho text
-
- address
-
- RETURN
-
-
- VERSION:
- call write "---High-Voltage-Hippo--- "version
- RETURN
-
- USAGE:
- call write "Command overview:"
- call write "-add P add SID to list"
- call write "-new [P] clear list"
- call write "-rand play a random song"
- call write "-next next song"
- call write "-prev prev song"
- call write "-nsub next subsong"
- call write "-psub prev subsong"
- call write "-sub [N] select arg subsong"
- call write "-pause pause/continue play"
- call write "-sort sort playlist alphabetically"
- call write "-test P just check, don't play"
- call write "-setpath S change HVSids path"
- call write "-setecho N change echo (0|1)"
- call write "-sethip S change Hippoplayer path"
- call write "-setcolor N change colortype for echo"
- call write "-setmax N change max number to echo"
- call write "-prefs echo your prefs "
- RETURN
-
-